<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="/res/common/js/jquery.1.9.1.min.js" ></script>
<script type="text/javascript" src="/res/third/artDialog/jquery.artDialog.js" ></script>
<link   type="text/css" href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet"  />
</head>
<body>
<div class="panel panel-info">
        <!-- Default panel contents -->
        <div class="panel-heading">
       			  [#assign canedit = false /]
        		  [@func_perm url="/role/ajax_save.do"]	
        		  [#assign canedit = true /]
				  <button type="button" class="btn btn-info" id="addButton" onclick="addSql();">
				  	<span class="glyphicon glyphicon-plus"></span>&nbsp;新增
				  </button>
				  [/@func_perm]
				  
				  
				  [#assign candel = false /]
			      [@func_perm url="/role/ajax_del.do"]<!-- 是否可以删除 -->
			      [#assign candel = true /]
			  	  [/@func_perm]
        </div>
        
        <!-- Table -->
        <table class="table table-bordered table-hover table-striped">
          <thead>
            <tr>
              <th width="50" >序号</th>
              <th width="150">名称</th>
              <th width="200">对应SQL</th>
              <th width="200">SQL描述</th>
              <th style="text-align: center" width="80">创建时间</th>
              <th style="width:80px;">操作</th>
            </tr>
          </thead>
          <tbody>
          [#if sqlList??]
          	[#list sqlList.list as sqllist]
          		<tr>
	          		<td align="center">${sqllist_index+1}</td>
	          		<td>${sqllist.name!}</td>
	          		<td>${sqllist.sqlstring!}</td>
	          		<td>${sqllist.descr!}</td>
	          		<td >${sqllist.createtime?string("yyyy-MM-dd HH:mm")}</td>
	          		<td>
	          			[#if canedit]
		          		<button type="button" class="btn btn-info btn-xs edits" onclick="edit('${sqllist.id}')">编辑</button>
		          		[/#if]
		          		[#if candel]
		          		<button type="button" class="btn btn-danger btn-xs delbtn" onclick="del('${sqllist.id}')">删除</button>
		          		[/#if]
	          		</td>
          		</tr>
          	[/#list]
          [/#if]
          </tbody>
        </table>
        <div class="panel-footer">[@fenye p = sqlList form = 'infoForm' /]</div>
      </div>

<script type="text/javascript">
function addSql(){
	$("#id").val("");
	$("#name").val("");
	$("#sqlstring").val("");
	dialog = art.dialog.load("新增SQL","/usefordevelopment/v_addsql.do");
}

function edit(id){
	dialog = art.dialog.load("编辑SQL","/usefordevelopment/v_addsql.do",{
		id:id
	});
}

function del(id){
	art.dialog.confirm('是否确认删除' , function(){
		$.ajax({
			url : '/usefordevelopment/o_deldevelop.do',
			type : 'post',
			dataType : 'json',
			data : {
				id : id
			},
			beforeSend:function(){
	            art.dialog.tips("删除中...");
	        },
			success : function(data){
				if(data.success){
					location.reload();
				}else{
					error_msg(data.msg , function(){location.reload();});
				}
			}
		});
	});
}


function sub(obj){
var data=$("form[name='formName']");
	$.ajax({
		url : '/usefordevelopment/ajax_add.do',
		type : 'post',
		dataType : 'json',
		data : data.serialize(),
		beforeSend:function(){
            art.dialog.tips("编辑中...");
        },
		success : function(data){
				if(data.success){
	               location.reload();
				}else{
					error_msg(data.msg , function(){location.reload();});
				}
		}
	});
}

</script>
</body>
</html>